package com.ms.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ms.entity.VolunteerEnroll;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 志愿者活动报名数据访问接口 - 使用MyBatis-Plus实现
 * 继承BaseMapper后可直接使用常见的CRUD操作
 */
@Mapper
public interface VolunteerEnrollMapper extends BaseMapper<VolunteerEnroll> {
    // MyBatis-Plus会自动提供常见的CRUD方法:
    // insert(VolunteerEnroll volunteerEnroll)
    // selectById(Serializable id)
    // selectList(Wrapper<VolunteerEnroll> queryWrapper)
    // updateById(VolunteerEnroll volunteerEnroll)
    // deleteById(Serializable id)
    // 等等...

    /**
     * 根据志愿者ID获取报名记录
     * @param volunteerId 志愿者ID
     * @return 报名记录列表
     */
    @Select("SELECT * FROM volunteer_enroll WHERE volunteer_id = #{volunteerId}")
    List<VolunteerEnroll> selectByVolunteerId(@Param("volunteerId") Long volunteerId);

    /**
     * 根据活动ID获取报名记录
     * @param activityId 活动ID
     * @return 报名记录列表
     */
    @Select("SELECT * FROM volunteer_enroll WHERE activity_id = #{activityId}")
    List<VolunteerEnroll> selectByActivityId(@Param("activityId") Long activityId);

    /**
     * 根据志愿者ID和活动ID获取特定报名记录
     * @param volunteerId 志愿者ID
     * @param activityId 活动ID
     * @return 报名记录
     */
    @Select("SELECT * FROM volunteer_enroll WHERE volunteer_id = #{volunteerId} AND activity_id = #{activityId}")
    VolunteerEnroll selectByVolunteerIdAndActivityId(@Param("volunteerId") Long volunteerId, @Param("activityId") Long activityId);
}